JavaScript Learning record day6-function variable scope, deconstruction assignment and method@ (learning) [JavaScript][TOC]1. ScopeIn JavaScript, variables that are var declared are actually scoped.If a variable is declared inside the function body,
Do you know the value of alert following JavaScript execution?
var foo = 1;
function Bar () {
if (!foo) {
var foo =;
alert (foo);
}
Bar ();
If you're surprised by the result of "10," you might want to take a good look at this article:
var a =
Now we have reached the core point of this article. The execution context code is divided into two basic stages for processing: Enter
Now we have reached the core point of this article. The execution context code is divided into two basic stages for
If the variable is related to the execution context, the variable should know where its data is stored and how to access it.
During JavaScript programming, we can't avoid declaring functions and variables to build our system successfully. But how
The first article mentions the promotion of variables, so let's talk about variable elevation and function promotion today. This knowledge point is a cliché, but some of the details of the blogger would like to take this opportunity to
For all types of execution contexts, some operations (such as variable initialization) and actions of variable objects are the same variable objects in different execution contexts.
For all types of execution contexts, some operations (such as
Document directory
1. JavaScript scope chain
2. In the function body, the priority of local variables is higher than that of global variables with the same name.
3. JavaScript does not have block-level scope.
4. variables declared in the
1. Events
In the hyperlink click, execute javascript:A Href= "Javascript: Alert ('haha ')">Haha/A>
The event concept is also available in Javascript. It can also be executed when a button is clicked.Javascript:• • "Javascript:" is required
Generally, various articles and JavaScript-related books claim: "whether it is using the var keyword (
Generally, various articles and JavaScript-related books claim that "a variable can be declared whether the var keyword is used (in the Global
1) Intro
Not long ago I set up a technology group in a MM asked a question like this, she posted the code as follows:
var a = 1;function hehe (){Window.alert (a);var a = 2;Window.alert (a);}Hehe ();
The results of the execution are as follows:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.